﻿using TSU.FAMC.ComputerEngineering.Classes.Enums;

namespace TSU.FAMC.ComputerEngineering.Classes.Circuits.Basis
{
    /// <summary>
    /// Connection joint (n - m realation).
    /// </summary>
    public class Joint : Element
    {
        /// <summary>
        /// Processes inputs signals and produces a result signal.
        /// </summary>
        /// <returns>Resulting signal. If Value of the signal is BooleanValue.UNDEFINED it means processing failed.</returns>
        public override Signal Process()
        {
            if (InputSignals.Count == 0)
            {
                var result = new Signal {Value = BooleanValue.Undefined};
                return result;
            }

            // returning last input signal
            return LastInputSignal;
        }

        /// <summary>
        /// Clones joint element.
        /// </summary>
        /// <returns>Cloned joint element.</returns>
        public override object Clone()
        {
            return new Joint
            {
                Delay = Delay,
                Id = Id,
                Name = Name
            };
        }
    }
}
